<template>
<h1>员工列表练习</h1>
  <input type="text" placeholder="请输入姓名" v-model="e.name">
  <input type="text" placeholder="请输入工资" v-model="e.salary">
  <input type="text" placeholder="请输入岗位" v-model="e.job">
  <hr>
  <button @click="add()">添加</button>
  <table border="1px">
    <tr>
      <th>编号</th>
      <th>姓名</th>
      <th>工资</th>
      <th>岗位</th>
    </tr>
    <tr v-for="(emp,i) in arr">
      <td>{{i+1}}</td>
      <td>{{emp.name}}</td>
      <td>{{emp.salary}}</td>
      <td>{{emp.job}}</td>
    </tr>

  </table>
</template>

<script setup>
import {ref} from "vue";
const arr =ref([]);
const e =ref({name:'',salary:'',job:''});
const add =()=>{
  let newEmp={
    name:e.value.name,
    salary:e.value.salary,
    job:e.value.job
  }
  arr.value.push(newEmp);
  e.value={name:'',salary:'',job:''};
}
</script>


<style scoped>

</style>